<?php

namespace app\api\controller;

use app\api\model\Venue;
use app\common\controller\Api;
use think\App;
use think\facade\Config;
use think\Request;

/**
 * 订单接口.
 */
class Order extends Api
{
    protected $noNeedLogin = ['orderPage'];
    protected $noNeedRight = ['*'];

    protected $model = null;
    /**
     * 构造方法
     * @access public
     * @param Request $request Request 对象
     */
    public function __construct(Request $request = null)
    {
        parent::__construct(App::getInstance());
        $this->model = new \app\api\model\Order();
    }

    public function _initialize()
    {
        parent::_initialize();
        if (!Config::get('fastadmin.usercenter')) {
            $this->error(__('User center already closed'));
        }
    }

    /**
     *  预约下单页
     */
    public function orderPage(){
        $requestData = $this->requestData;
        $user = $this->auth->getUserinfo();
        $data  = $this->model->orderPage($requestData,$user);
        $this->getReturnData($data);
    }

    /**
     *  预约下单提交
     */
    public function orderPay(){
        $requestData = $this->requestData;
        $user = $this->auth->getUserinfo();
        $data  = $this->model->orderPay($requestData, $user);
        $this->getReturnData($data);
    }


    public function orderPays(){
        $requestData = $this->requestData;
        $user = $this->auth->getUserinfo();
        $data  = $this->model->orderPays($requestData, $user);
        $this->getReturnData($data);
    }

    /**
     *  订单列表
     */
    public function orderList(){
        $requestData = $this->requestData;
        $user = $this->auth->getUserinfo();
        $data  = $this->model->orderList($requestData, $user);
        $this->getReturnData($data);
    }

    /**
     *  订单详情
     */
    public function orderDetails(){
        $requestData = $this->requestData;
        $user = $this->auth->getUserinfo();
        $data  = $this->model->orderDetails($requestData, $user);
        $this->getReturnData($data);
    }

    /**
     *  去支付
     */
    public function orderToPay(){
        $requestData = $this->requestData;
        $user = $this->auth->getUserinfo();
        $data  = $this->model->orderToPay($requestData, $user);
        $this->getReturnData($data);
    }

    /**
     *  取消订单
     */
    public function orderCancel(){
        $requestData = $this->requestData;
        $user = $this->auth->getUserinfo();
        $data  = $this->model->orderCancel($requestData, $user);
        $this->getReturnData($data);
    }

    /**
     *  申请退款
     */
    public function orderRefund(){
        $requestData = $this->requestData;
        $user = $this->auth->getUserinfo();
        $data  = $this->model->orderRefund($requestData, $user);
        $this->getReturnData($data);
    }

    /**
     *  开锁
     */
    public function openDoor(){
        $requestData = $this->requestData;
        $user = $this->auth->getUserinfo();
        $data  = $this->model->openDoor($requestData, $user);
        $this->getReturnData($data);
    }

    /**
     *  注册
     */
    public function registerDoor(){
        $requestData = $this->requestData;
        $user = $this->auth->getUserinfo();
        $data  = $this->model->registerDoor($requestData, $user);
        $this->getReturnData($data);
    }
}
